﻿using System;
using System.Collections;
using System.Collections.Generic;
using NHibernate;
using NhJump.Persistence.Batching;
using NUnit.Framework;
using Rhino.Mocks;

namespace NhJump.Persistence.Tests.Batching
{
    [TestFixture]
    public class MultiCriteriaBatchExecuterFixture
    {
        [Test]
        public void Execute_SingleCriteriaWithResultAction_AddsCriteriaToMultiCriteria()
        {
            var stubSession = MockRepository.GenerateStub<ISession>();
            var mockMultiCriteria = MockRepository.GenerateMock<IMultiCriteria>();
            var stubCriteria = MockRepository.GenerateStub<ICriteria>();

            stubSession.Stub(stub => stub.CreateMultiCriteria()).Return(mockMultiCriteria);
            mockMultiCriteria.Expect(mock => mock.Add(stubCriteria)).Return(null);

            var batch = new List<CriteriaWithResultAction>
                                {
                                    new CriteriaWithResultAction(stubCriteria, null)
                                };
            
            var criteriaBatchExecuter = new MultiCriteriaBatchExecuter(stubSession);
            criteriaBatchExecuter.Execute(batch);

            mockMultiCriteria.VerifyAllExpectations();
        }
    }
}
